-
Notifications
You must be signed in to change notification settings - Fork 8k
[PoC] drivers: ethernet/wifi: Use NVMEM cell to get MAC address #96598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
1a5832d
to
bd8b9b6
Compare
9afd50b
to
8241eb8
Compare
WIP Signed-off-by: Pieter De Gendt <[email protected]>
Given an ethernet MAC configuration struct, load a MAC address into a provided array. Signed-off-by: Pieter De Gendt <[email protected]>
Turn ethernet controller devicetree nodes into NVMEM consumers. Allow passing mac-address cells. Signed-off-by: Pieter De Gendt <[email protected]>
Rework the Atmel SAM GMAC driver to read a MAC address from the provided NVMEM cell instead of using I2C commands directly. Signed-off-by: Pieter De Gendt <[email protected]>
Create a generic Wi-Fi interface binding file which includes the ethernet-controller.yaml bindings and include it in Nordic's WLAN interface binding. Signed-off-by: Pieter De Gendt <[email protected]>
Allow setting the MAC address for the nRF Wi-Fi interface with a configuration derived from the devicetree. This allows to use an NVMEM cell as MAC address storage. Signed-off-by: Pieter De Gendt <[email protected]>
8241eb8
to
8ac0a2f
Compare
|
/* Copy the static part */ | ||
memcpy(mac_addr, cfg->addr, cfg->addr_len); | ||
|
||
if (cfg->type == NET_ETH_MAC_STATIC && cfg->addr_len == NET_ETH_ADDR_LEN) { | ||
/* Complete static address */ | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to have no difference between the static mac address and the default. as most drivers set the mac address from the dt as the initial value of the mac address in the data struct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain a bit what you mean here? I don't fully understand.
This static MAC address is when you have the following:
eth-driver {
local-mac-address = [02 02 03 04 05 06];
};
This should only ever be used during testing. An alternative is have the OUI in the static part:
eth-driver {
local-mac-address = [00 04 25];
zephyr,random-mac-address;
};
/* or */
eth-driver {
local-mac-address = [00 04 25];
nvmem-cells = <&mac_address>;
nvmem-cell-names = "mac-address";
};
Maybe the naming should be changed in that case to something like mac-address-prefix
?
enum net_eth_mac_type type; | ||
uint8_t addr[NET_ETH_ADDR_LEN]; | ||
uint8_t addr_len; | ||
struct nvmem_cell cell; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
struct nvmem_cell cell; | |
#if defined(CONFIG_NVMEM) | |
struct nvmem_cell cell; | |
#endif |
should not increase size if not needed
A proof-of-concept using PR #96379 as an alternative for #74835.
Note that this loads the MAC address during driver initialization. A more complete (but complex) solution would be to move it to the network interface initialization.